<?php

namespace App\Cms\Controller;

class Event extends Base {

    public function index() {
        
        $this->title = '公告';
        
        $id = intval($this->request->get('id'));

        $count = Cms()->Event()->countAll();

        /* 分页 */
        $this->page_size = 10;
        $pager = $this->_createPager($count, array('id' => $id));
        $length = $pager['length'];
        $start = $pager['offset'];
        $this->assign('pager', $pager);

        $this->rows = Cms()->Event()->getAll($start, $length);
    }

    public function page() {

        $id = intval($this->request->get('id'));

        $detail = Cms()->Event()->get($id);

        if (!$detail) {
            fail('参数错误');
        }
        
        $this->title = "{$detail['title']} - 公告";
        
        $detail['content'] = htmlspecialchars_decode($detail['content']);

        $this->detail = $detail;
    }

}
